home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C++ / Applications / NeuroSim 1.0 / .h / CNeuron.h < prev    next >
Text File  |  1996-02-19  |  3KB  |  96 lines

  1. // ===========================================================================
  2. //    CNeuron.h                    ©1996 Timo Eloranta
  3. // ===========================================================================
  4. //  An abstract neuron class - derived from LLink to be queueable
  5.  
  6. #pragma once                        // Include this header only once
  7.  
  8. #include "NS_Types.h"
  9.                         
  10. #include <LList.h>                    // PowerPlant list class
  11. #include <LLink.h>                    // PowerPlant link class
  12.  
  13. class CNeuron;                        // Forward class declarations
  14. class CNeuralNet;
  15.  
  16. typedef CNeuron *    CNeuronPtr;
  17.  
  18. class CNeuron : public LLink
  19. {
  20.     protected:
  21.         Uint16        mState;            // Number of impulses received
  22.         Uint16        mMaxState;        // If mState gets bigger than this
  23.                                     // the neuron will light up
  24.         
  25.         Uint16        mCol;            // Location: column    ( > 0 )
  26.         Uint16        mRow;            // Location: row    ( > 0 )
  27.  
  28.         LList        mNextOnes;        // A list of the neurons to which
  29.                                     // this neuron is connected to
  30.  
  31.         static CNeuralNet *sNet;    // A pointer to the net which
  32.                                     // owns this neuron (static!)
  33.         
  34.                 // --- Drawing related attributes --- //
  35.         
  36.         Point        mCenter;        // Location on the screen
  37.         
  38.         Boolean        mRedrawNeeded;    // Has this neuron changed so
  39.                                     // that it should be redrawn?
  40.         Boolean        mDestination;    // Should this neuron be drawn
  41.                                     // with a "yellow ring" around it?
  42.         Boolean        mConnDirty;        // Are the connections in need
  43.                                     // of redrawing?
  44.         Boolean        mConnLit;        // Are the connections lit?
  45.         
  46.         Rect        mConnRect;        // The rectangle inside of which all
  47.                                     // of the connected neurons are
  48.                                     // (used when drawing connections)
  49.                                     
  50.         virtual void     SetNeuronState( Uint16 inState );
  51.         
  52.     public:
  53.                          CNeuron();
  54.         virtual            ~CNeuron() {};
  55.     
  56.         virtual void    IncState();
  57.         
  58.         virtual void     SetNeuronPos( Uint16 inCol, Uint16 inRow );
  59.         virtual void     GetNeuronPos( Uint16 & outX, Uint16 & outY) const;
  60.         
  61.         virtual Boolean    IsReceptor() const;
  62.  
  63.         virtual void    AddToNeuronList( const CNeuronPtr inNeuronPtr );
  64.         virtual Boolean    IsConnectedTo( const CNeuronPtr inNeuronPtr );
  65.  
  66.         static void        SetNet( CNeuralNet *inNet );
  67.  
  68.             // The following are pure virtual functions.
  69.             // Concrete subclasses must override them!
  70.         
  71.         virtual void    DoClickAction( Boolean inOptionKeyDown )    = 0;                    
  72.         virtual Boolean ShouldLightUp() const                        = 0;
  73.         virtual void    DoLightUpAction()                            = 0;
  74.         virtual void    SetPostLightUpState()                        = 0;
  75.  
  76.                 // --- Drawing related member functions --- //
  77.         
  78.         virtual void    Draw( const Rect & inRect );
  79.         virtual void    ForceRedraw()
  80.                         { mRedrawNeeded = true; }
  81.         virtual Boolean    RedrawNeeded() const
  82.                         { return mRedrawNeeded; };
  83.  
  84.         virtual void    SetDestinationFlag( Boolean inTrueOrFalse )
  85.                         { mDestination = inTrueOrFalse; };
  86.  
  87.         virtual void    DrawConnections();
  88.         virtual Boolean    ConnectionsDirty() const
  89.                         { return mConnDirty; };
  90.                         
  91.         virtual void    SetCenterPoint( Point & inCenter )
  92.                         { mCenter = inCenter; };
  93.         virtual void    SetConnectionRect( Rect & inRect )
  94.                         { mConnRect = inRect; };
  95. };
  96.